const request = require("sync-request")
const _ = require("underscore")
const fs = require("fs")

const url = "https://repo.huaweicloud.com/repository/npm/-/all"
// const url = "https://replicate.npmjs.com/_all_docs"
let body = request("GET", url).getBody()
var json = JSON.parse(body);
var data = _.filter(json, function (val) {
    return val.id != val.key;
});
// var packages = { data: data };

fs.writeFileSync('npmall.json', body, 'utf8');
fs.writeFileSync('diff.json', JSON.stringify(data), "utf-8");